package com.flying.carclub.http;


import java.io.Serializable;

import okhttp3.Request;

/**
 * Created by xcheng on 2015/9/17.
 */
public class ApiHandleParams implements Cloneable, Serializable {
    private static final long serialVersionUID = 8140360607472554180L;
    private String token;               //服务唯一令牌
    private Request request;            //网络请求码
    private ApiHandler apiHandler;      //网络处理的handler
    private BaseParser<?> parser;       //json解析器
    private Object response;            //接口返回的数据
    private OkHttpStatus okHttpStatus;      //服务状态码
    private Object responseObj;//数据
    private int connectTimeOut = OkRequestParams.DEFAULT_TIME_OUT;
    private boolean cacheResopnse;// 是否缓存服务响应结果
    private boolean showError;// 弹出错误Toast
    private boolean bCacheExist;// 本地存在该服务的缓存
    private boolean bUseHttpRespones;// 是否在响应中返回httpRespones对象;

    public String getToken() {
        return token;
    }

    public void setToken(String token) {
        this.token = token;
    }

    public Request getRequest() {
        return request;
    }

    public void setRequest(Request request) {
        this.request = request;
    }

    public ApiHandler getApiHandler() {
        return apiHandler;
    }

    public void setApiHandler(ApiHandler apiHandler) {
        this.apiHandler = apiHandler;
    }

    public BaseParser<?> getParser() {
        return parser;
    }

    public void setParser(BaseParser<?> parser) {
        this.parser = parser;
    }

    public Object getResponse() {
        return response;
    }

    public void setResponse(Object response) {
        this.response = response;
    }

    public OkHttpStatus getOkHttpStatus() {
        return okHttpStatus;
    }

    public void setOkHttpStatus(OkHttpStatus okHttpStatus) {
        this.okHttpStatus = okHttpStatus;
    }

    public boolean isCacheResopnse() {
        return cacheResopnse;
    }

    public void setCacheResopnse(boolean cacheResopnse) {
        this.cacheResopnse = cacheResopnse;
    }

    public boolean isShowError() {
        return showError;
    }

    public void setShowError(boolean showError) {
        this.showError = showError;
    }

    public boolean isbCacheExist() {
        return bCacheExist;
    }

    public void setbCacheExist(boolean bCacheExist) {
        this.bCacheExist = bCacheExist;
    }

    public boolean isbUseHttpRespones() {
        return bUseHttpRespones;
    }

    public void setbUseHttpRespones(boolean bUseHttpRespones) {
        this.bUseHttpRespones = bUseHttpRespones;
    }

    public Object getResponseObj() {
        return responseObj;
    }

    public void setResponseObj(Object responseObj) {
        this.responseObj = responseObj;
    }

    public int getConnectTimeOut() {
        return connectTimeOut;
    }

    public void setConnectTimeOut(int connectTimeOut) {
        this.connectTimeOut = connectTimeOut;
    }

    public void cancel() {
        setOkHttpStatus(OkHttpStatus.CANCLE);
        OkHttpExecutor.instance.cancelRequestByTag(token);
    }
}
